
clear all 

//define folder global here

gl Inputs "$folder\1_Inputs"
gl Intermediate "$folder\2_Intermediate"
gl Outputs "$folder\3_Outputs"

********************************************************************************

use "${Intermediate}\Combined for forloops.dta", clear

keep if inlist(group, "gr0", "gr1")
keep if inlist(spec, "ldv", "ivac")
keep if inlist(outcome, "earn", "inde", "cred", "zero", "deli", "auto")

levelsof outcome, local(outcomes)
levelsof group, local(groups)
levelsof spec, local(specs)
levelsof time, local(times)
levelsof geo, local(geos)
levelsof item, local(items)

foreach outx in `outcomes' {
	local id1 = "`outx'"
	
	foreach grox in `groups' {
		local id2 = "`grox'"
		
		foreach spex in `specs' {
			local id3 = "`spex'"
			
			foreach timx in `times' {
				local id4 = "`timx'"
				
				foreach geox in `geos' {
					local id5 = "`geox'"
					
					foreach itex in `items' {
						local id6 = "`itex'"
		
					levelsof value if 	outcome=="`outx'" & ///
										group=="`grox'" & ///
										spec=="`spex'" & ///
										time=="`timx'" & ///
										geo=="`geox'" & ///
										item=="`itex'" , ///
						clean local(`id1'_`id2'_`id3'_`id4'_`id5'_`id6')
						di "`id1'_`id2'_`id3'_`id4'_`id5'_`id6'"
						
					}
				}
			}
		}
	}
}

			
gl x " "

********************************************************************************
********************************************************************************
**# TABLE H.3


texdoc init "${Outputs}/Supplementary data_Table_H3.tex", replace force 
tex {\footnotesize \begin{tabular}{l c c c c c c c c c c c c c c c} \hline \toprule ///
	& \multicolumn{7}{c}{\textbf{1-4 Quarters After Filing}} ///
	& & \multicolumn{7}{c}{\textbf{5-8 Quarters After Filing}} \\
	
tex \cmidrule{2-8} \cmidrule{10-16}
	
tex & \multicolumn{3}{c}{Non-Great Recession} & & \multicolumn{3}{c}{Great Recession} & ///
	& \multicolumn{3}{c}{Non-Great Recession} & & \multicolumn{3}{c}{Great Recession} \\ 
	
tex \cmidrule{2-4} \cmidrule{6-8} \cmidrule{10-12} \cmidrule{14-16}	
	
tex & $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV & ///
	& $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV & ///
	& $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV & ///
	& $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV \\

tex & (1) & (2) & (3) & & (4) & (5) & (6) & & (7) & (8) & (9) & & (10) & (11) & (12) \\

tex \cmidrule{2-4} \cmidrule{6-8} \cmidrule{10-12} \cmidrule{14-16}	

tex \multicolumn{16}{l}{ } \\
tex \textbf{Earnings:} 	& `earn_gr0_ldv_q0104_b_m' 		& `earn_gr0_ldv_q0104_b_co' 		& `earn_gr0_ivac_q0104_b_co' & ///
						& `earn_gr1_ldv_q0104_b_m' 		& `earn_gr1_ldv_q0104_b_co' 		& `earn_gr1_ivac_q0104_b_co' & ///
						& `earn_gr0_ldv_q0508_b_m' 		& `earn_gr0_ldv_q0508_b_co' 		& `earn_gr0_ivac_q0508_b_co' & ///
						& `earn_gr1_ldv_q0508_b_m' 		& `earn_gr1_ldv_q0508_b_co' 		& `earn_gr1_ivac_q0508_b_co' \\
						
tex  				 	& `earn_gr0_ldv_q0104_b_mse' 		& `earn_gr0_ldv_q0104_b_se' 		& `earn_gr0_ivac_q0104_b_se'  & ///
						& `earn_gr1_ldv_q0104_b_mse' 		& `earn_gr1_ldv_q0104_b_se' 		& `earn_gr1_ivac_q0104_b_se'  & ///
						& `earn_gr0_ldv_q0508_b_mse' 		& `earn_gr0_ldv_q0508_b_se' 		& `earn_gr0_ivac_q0508_b_se'  & ///
						& `earn_gr1_ldv_q0508_b_mse' 		& `earn_gr1_ldv_q0508_b_se' 		& `earn_gr1_ivac_q0508_b_se' \\

tex 					& \multicolumn{3}{r}{[`earn_gr0_ivac_q0104_b_obs']} & ///
						& \multicolumn{3}{r}{[`earn_gr1_ivac_q0104_b_obs']} & ///						
						& \multicolumn{3}{r}{[`earn_gr0_ivac_q0508_b_obs']} & ///
						& \multicolumn{3}{r}{[`earn_gr1_ivac_q0508_b_obs']}  \\						
						
tex \multicolumn{16}{l}{\textit{By Location}} \\						
tex ~~~Cook County		& `earn_gr0_ldv_q0104_c_m' 		& `earn_gr0_ldv_q0104_c_co' 		& `earn_gr0_ivac_q0104_c_co' & ///
						& `earn_gr1_ldv_q0104_c_m' 		& `earn_gr1_ldv_q0104_c_co' 		& `earn_gr1_ivac_q0104_c_co' & ///
						& `earn_gr0_ldv_q0508_c_m' 		& `earn_gr0_ldv_q0508_c_co' 		& `earn_gr0_ivac_q0508_c_co'  & ///
						& `earn_gr1_ldv_q0508_c_m' 		& `earn_gr1_ldv_q0508_c_co' 		& `earn_gr1_ivac_q0508_c_co' \\
						
tex  				 	& `earn_gr0_ldv_q0104_c_mse' 		& `earn_gr0_ldv_q0104_c_se' 		& `earn_gr0_ivac_q0104_c_se'  &  ///
						& `earn_gr1_ldv_q0104_c_mse' 		& `earn_gr1_ldv_q0104_c_se' 		& `earn_gr1_ivac_q0104_c_se'  & ///
						& `earn_gr0_ldv_q0508_c_mse' 		& `earn_gr0_ldv_q0508_c_se' 		& `earn_gr0_ivac_q0508_c_se'  &  ///
						& `earn_gr1_ldv_q0508_c_mse' 		& `earn_gr1_ldv_q0508_c_se' 		& `earn_gr1_ivac_q0508_c_se' \\

tex 					& \multicolumn{3}{r}{[`earn_gr0_ivac_q0104_c_obs']} & ///
						& \multicolumn{3}{r}{[`earn_gr1_ivac_q0104_c_obs']} & ///						
						& \multicolumn{3}{r}{[`earn_gr0_ivac_q0508_c_obs']} & ///
						& \multicolumn{3}{r}{[`earn_gr1_ivac_q0508_c_obs']}  \\

tex ~~~New York 		& `earn_gr0_ldv_q0104_n_m' 		& `earn_gr0_ldv_q0104_n_co' 		& `earn_gr0_ivac_q0104_n_co'  & ///
						& `earn_gr1_ldv_q0104_n_m' 		& `earn_gr1_ldv_q0104_n_co' 		& `earn_gr1_ivac_q0104_n_co' &  ///
						& `earn_gr0_ldv_q0508_n_m' 		& `earn_gr0_ldv_q0508_n_co' 		& `earn_gr0_ivac_q0508_n_co'  & ///
						& `earn_gr1_ldv_q0508_n_m' 		& `earn_gr1_ldv_q0508_n_co' 		& `earn_gr1_ivac_q0508_n_co' \\
						
tex  				 	& `earn_gr0_ldv_q0104_n_mse' 		& `earn_gr0_ldv_q0104_n_se' 		& `earn_gr0_ivac_q0104_n_se'  &  ///
						& `earn_gr1_ldv_q0104_n_mse' 		& `earn_gr1_ldv_q0104_n_se' 		& `earn_gr1_ivac_q0104_n_se'  & ///
						& `earn_gr0_ldv_q0508_n_mse' 		& `earn_gr0_ldv_q0508_n_se' 		& `earn_gr0_ivac_q0508_n_se'  & ///
						& `earn_gr1_ldv_q0508_n_mse' 		& `earn_gr1_ldv_q0508_n_se' 		& `earn_gr1_ivac_q0508_n_se' \\

tex 					& \multicolumn{3}{r}{[`earn_gr0_ivac_q0104_n_obs']} & ///
						& \multicolumn{3}{r}{[`earn_gr1_ivac_q0104_n_obs']} & ///						
						& \multicolumn{3}{r}{[`earn_gr0_ivac_q0508_n_obs']} & ///
						& \multicolumn{3}{r}{[`earn_gr1_ivac_q0508_n_obs']}  \\
						
						
tex \bottomrule \\
tex	\end{tabular} }
texdoc close



********************************************************************************
********************************************************************************
**# TABLE H.4


texdoc init "${Outputs}/Supplementary data_Table_H4.tex", replace force 
tex {\footnotesize \begin{tabular}{l c c c c c c c c c c c c c c c} \hline \toprule ///
	& \multicolumn{7}{c}{\textbf{1-4 Quarters After Filing}} ///
	& & \multicolumn{7}{c}{\textbf{5-8 Quarters After Filing}} \\
	
tex \cmidrule{2-8} \cmidrule{10-16}
	
tex & \multicolumn{3}{c}{Non-Great Recession} & & \multicolumn{3}{c}{Great Recession} & ///
	& \multicolumn{3}{c}{Non-Great Recession} & & \multicolumn{3}{c}{Great Recession} \\ 
	
tex \cmidrule{2-4} \cmidrule{6-8} \cmidrule{10-12} \cmidrule{14-16}	
	
tex & $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV & ///
	& $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV & ///
	& $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV & ///
	& $ {\scriptsize \mathbb{E}[Y \vert E=0]}$ & OLS & IV \\

tex & (1) & (2) & (3) & & (4) & (5) & (6) & & (7) & (8) & (9) & & (10) & (11) & (12) \\

tex \cmidrule{2-4} \cmidrule{6-8} \cmidrule{10-12} \cmidrule{14-16}	

tex \multicolumn{16}{l}{ } \\
						
tex Financial health index: 	& `inde_gr0_ldv_q0104_c_m' 		& `inde_gr0_ldv_q0104_c_co' 		& `inde_gr0_ivac_q0104_c_co' & ///
						& `inde_gr1_ldv_q0104_c_m' 		& `inde_gr1_ldv_q0104_c_co' 		& `inde_gr1_ivac_q0104_c_co' & ///
						& `inde_gr0_ldv_q0508_c_m' 		& `inde_gr0_ldv_q0508_c_co' 		& `inde_gr0_ivac_q0508_c_co'  & ///
						& `inde_gr1_ldv_q0508_c_m' 		& `inde_gr1_ldv_q0508_c_co' 		& `inde_gr1_ivac_q0508_c_co' \\
						
tex  				 	& `inde_gr0_ldv_q0104_c_mse' 		& `inde_gr0_ldv_q0104_c_se' 		& `inde_gr0_ivac_q0104_c_se'  &  ///
						& `inde_gr1_ldv_q0104_c_mse' 		& `inde_gr1_ldv_q0104_c_se' 		& `inde_gr1_ivac_q0104_c_se'  & ///
						& `inde_gr0_ldv_q0508_c_mse' 		& `inde_gr0_ldv_q0508_c_se' 		& `inde_gr0_ivac_q0508_c_se'  &  ///
						& `inde_gr1_ldv_q0508_c_mse' 		& `inde_gr1_ldv_q0508_c_se' 		& `inde_gr1_ivac_q0508_c_se' \\

tex 					& \multicolumn{3}{r}{[`inde_gr0_ivac_q0104_c_obs']} & ///
						& \multicolumn{3}{r}{[`inde_gr1_ivac_q0104_c_obs']} & ///						
						& \multicolumn{3}{r}{[`inde_gr0_ivac_q0508_c_obs']} & ///
						& \multicolumn{3}{r}{[`inde_gr1_ivac_q0508_c_obs']}  \\

tex \midrule						
tex \multicolumn{16}{c}{ } \\						
tex Credit Score: & `cred_gr0_ldv_q0104_c_m' 		& `cred_gr0_ldv_q0104_c_co' 		& `cred_gr0_ivac_q0104_c_co' & ///
						& `cred_gr1_ldv_q0104_c_m' 		& `cred_gr1_ldv_q0104_c_co' 		& `cred_gr1_ivac_q0104_c_co' & ///
						& `cred_gr0_ldv_q0508_c_m' 		& `cred_gr0_ldv_q0508_c_co' 		& `cred_gr0_ivac_q0508_c_co'  & ///
						& `cred_gr1_ldv_q0508_c_m' 		& `cred_gr1_ldv_q0508_c_co' 		& `cred_gr1_ivac_q0508_c_co' \\
						
tex  				 	& `cred_gr0_ldv_q0104_c_mse' 		& `cred_gr0_ldv_q0104_c_se' 		& `cred_gr0_ivac_q0104_c_se'  &  ///
						& `cred_gr1_ldv_q0104_c_mse' 		& `cred_gr1_ldv_q0104_c_se' 		& `cred_gr1_ivac_q0104_c_se'  & ///
						& `cred_gr0_ldv_q0508_c_mse' 		& `cred_gr0_ldv_q0508_c_se' 		& `cred_gr0_ivac_q0508_c_se'  &  ///
						& `cred_gr1_ldv_q0508_c_mse' 		& `cred_gr1_ldv_q0508_c_se' 		& `cred_gr1_ivac_q0508_c_se' \\

tex 					& \multicolumn{3}{r}{[`cred_gr0_ivac_q0104_c_obs']} & ///
						& \multicolumn{3}{r}{[`cred_gr1_ivac_q0104_c_obs']} & ///						
						& \multicolumn{3}{r}{[`cred_gr0_ivac_q0508_c_obs']} & ///
						& \multicolumn{3}{r}{[`cred_gr1_ivac_q0508_c_obs']}  \\

tex \midrule
tex \multicolumn{16}{c}{ } \\
tex No open revolving account: 	& `zero_gr0_ldv_q0104_c_m' 		& `zero_gr0_ldv_q0104_c_co' 		& `zero_gr0_ivac_q0104_c_co' & ///
						& `zero_gr1_ldv_q0104_c_m' 		& `zero_gr1_ldv_q0104_c_co' 		& `zero_gr1_ivac_q0104_c_co' & ///
						& `zero_gr0_ldv_q0508_c_m' 		& `zero_gr0_ldv_q0508_c_co' 		& `zero_gr0_ivac_q0508_c_co'  & ///
						& `zero_gr1_ldv_q0508_c_m' 		& `zero_gr1_ldv_q0508_c_co' 		& `zero_gr1_ivac_q0508_c_co' \\
						
tex  				 	& `zero_gr0_ldv_q0104_c_mse' 		& `zero_gr0_ldv_q0104_c_se' 		& `zero_gr0_ivac_q0104_c_se'  &  ///
						& `zero_gr1_ldv_q0104_c_mse' 		& `zero_gr1_ldv_q0104_c_se' 		& `zero_gr1_ivac_q0104_c_se'  & ///
						& `zero_gr0_ldv_q0508_c_mse' 		& `zero_gr0_ldv_q0508_c_se' 		& `zero_gr0_ivac_q0508_c_se'  &  ///
						& `zero_gr1_ldv_q0508_c_mse' 		& `zero_gr1_ldv_q0508_c_se' 		& `zero_gr1_ivac_q0508_c_se' \\

tex 					& \multicolumn{3}{r}{[`zero_gr0_ivac_q0104_c_obs']} & ///
						& \multicolumn{3}{r}{[`zero_gr1_ivac_q0104_c_obs']} & ///						
						& \multicolumn{3}{r}{[`zero_gr0_ivac_q0508_c_obs']} & ///
						& \multicolumn{3}{r}{[`zero_gr1_ivac_q0508_c_obs']}  \\

tex \midrule
tex \multicolumn{16}{c}{ } \\
tex Total balance: collections	& `deli_gr0_ldv_q0104_c_m' 		& `deli_gr0_ldv_q0104_c_co' 		& `deli_gr0_ivac_q0104_c_co' & ///
						& `deli_gr1_ldv_q0104_c_m' 		& `deli_gr1_ldv_q0104_c_co' 		& `deli_gr1_ivac_q0104_c_co' & ///
						& `deli_gr0_ldv_q0508_c_m' 		& `deli_gr0_ldv_q0508_c_co' 		& `deli_gr0_ivac_q0508_c_co'  & ///
						& `deli_gr1_ldv_q0508_c_m' 		& `deli_gr1_ldv_q0508_c_co' 		& `deli_gr1_ivac_q0508_c_co' \\
						
tex and delinquencies:	& `deli_gr0_ldv_q0104_c_mse' 		& `deli_gr0_ldv_q0104_c_se' 		& `deli_gr0_ivac_q0104_c_se'  &  ///
						& `deli_gr1_ldv_q0104_c_mse' 		& `deli_gr1_ldv_q0104_c_se' 		& `deli_gr1_ivac_q0104_c_se'  & ///
						& `deli_gr0_ldv_q0508_c_mse' 		& `deli_gr0_ldv_q0508_c_se' 		& `deli_gr0_ivac_q0508_c_se'  &  ///
						& `deli_gr1_ldv_q0508_c_mse' 		& `deli_gr1_ldv_q0508_c_se' 		& `deli_gr1_ivac_q0508_c_se' \\

tex 					& \multicolumn{3}{r}{[`deli_gr0_ivac_q0104_c_obs']} & ///
						& \multicolumn{3}{r}{[`deli_gr1_ivac_q0104_c_obs']} & ///						
						& \multicolumn{3}{r}{[`deli_gr0_ivac_q0508_c_obs']} & ///
						& \multicolumn{3}{r}{[`deli_gr1_ivac_q0508_c_obs']}  \\

tex \midrule
tex \multicolumn{16}{c}{ } \\						
tex Any auto loan or lease:	& `auto_gr0_ldv_q0104_c_m' 		& `auto_gr0_ldv_q0104_c_co' 		& `auto_gr0_ivac_q0104_c_co' & ///
						& `auto_gr1_ldv_q0104_c_m' 		& `auto_gr1_ldv_q0104_c_co' 		& `auto_gr1_ivac_q0104_c_co' & ///
						& `auto_gr0_ldv_q0508_c_m' 		& `auto_gr0_ldv_q0508_c_co' 		& `auto_gr0_ivac_q0508_c_co'  & ///
						& `auto_gr1_ldv_q0508_c_m' 		& `auto_gr1_ldv_q0508_c_co' 		& `auto_gr1_ivac_q0508_c_co' \\
						
tex  				 	& `auto_gr0_ldv_q0104_c_mse' 		& `auto_gr0_ldv_q0104_c_se' 		& `auto_gr0_ivac_q0104_c_se'  &  ///
						& `auto_gr1_ldv_q0104_c_mse' 		& `auto_gr1_ldv_q0104_c_se' 		& `auto_gr1_ivac_q0104_c_se'  & ///
						& `auto_gr0_ldv_q0508_c_mse' 		& `auto_gr0_ldv_q0508_c_se' 		& `auto_gr0_ivac_q0508_c_se'  &  ///
						& `auto_gr1_ldv_q0508_c_mse' 		& `auto_gr1_ldv_q0508_c_se' 		& `auto_gr1_ivac_q0508_c_se' \\

tex 					& \multicolumn{3}{r}{[`auto_gr0_ivac_q0104_c_obs']} & ///
						& \multicolumn{3}{r}{[`auto_gr1_ivac_q0104_c_obs']} & ///						
						& \multicolumn{3}{r}{[`auto_gr0_ivac_q0508_c_obs']} & ///
						& \multicolumn{3}{r}{[`auto_gr1_ivac_q0508_c_obs']}  \\

tex \bottomrule \\
tex	\end{tabular} }
texdoc close



